package com.onesports.intelligent.k12.polarlight.controller.organization.product;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.onesports.intelligent.k12.polarlight.common.utils.ResultUtil;
import com.onesports.intelligent.k12.polarlight.constant.ApiPathConstants;
import com.onesports.intelligent.k12.polarlight.domain.dto.cls.ClassPageDTO;
import com.onesports.intelligent.k12.polarlight.domain.vo.cls.ClassDetailVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.cls.ClassPageVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.course.ClassMienVO;
import com.onesports.intelligent.k12.polarlight.service.grade.ClassInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author FPH
 * @since 2022年7月14日11:40:25
 */
@RestController
@RequiredArgsConstructor
@RequestMapping(ApiPathConstants.PRODUCT_CLS)
@Api(tags = "机构端-教务管理-班级管理")
@PreAuthorize("isAuthenticated()")
public class ClassManageController {

    private final ClassInfoService classInfoService;

    @PostMapping("page")
    @ApiOperation("分页")
    public ResponseEntity<IPage<ClassPageVO>> getPage(@RequestBody @Valid ClassPageDTO dto){
        return ResultUtil.success(classInfoService.getPage(dto));
    }

    @GetMapping("detail")
    @ApiOperation("详情")
    public ResponseEntity<ClassDetailVO> getPage(String classId){
        return ResultUtil.success(classInfoService.getClassDetail(classId));
    }

    @GetMapping("mien")
    @ApiOperation("班级风采")
    public ResponseEntity<ClassMienVO> getMienByClass(String classId){
        return ResultUtil.success(classInfoService.getMienByClass(classId));
    }

}
